﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LogManager.Base.Data
{
    public class EventService
    {
        private IServerRepository _serverRepository;

        public EventService(IServerRepository serverRepository)
        {
            _serverRepository = serverRepository;
        }

        public IEnumerable<IEvent> GetAllEvents()
        {
            return _serverRepository.All()
                .SelectMany(s => s.Logs().All()
                    .SelectMany(l => l.Events().All()));
        }

        public IEnumerable<IEvent> GetEventsLog(string serverName,string logName)
        {
            return _serverRepository.Get(serverName).Logs()
                .Get(logName).Events().All();
        }
    }
}
